package com.vidyu.businesslayer.businessentities;

import com.vidyu.businesslayer.businesscomponents.Constants;

import javax.persistence.*;

/**
 * Created with IntelliJ IDEA.
 * User: eyalsa
 * Date: 4/16/13
 * Time: 3:09 PM
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "userInProjects")
@NamedQueries({
        @NamedQuery(
                name = "getUsersInProjectByStatus",
                query = "FROM com.vidyu.businesslayer.businessentities.UserInProject as userInProject " +
                        "WHERE  userInProject.projectId = ? AND userInProject.status = ?"
        )})
public class UserInProject {
    private static final long serialVersionUID = 3597073186701729397L;
    private long id = Constants.NON_VALID_ID;
    private long contractorId;
    private long projectId;
    private ProjectStatus status;

    public enum ProjectStatus {
        NONE(0), APPLY(1), SUBMITTED(2), REGRET(3), APPROVED(4),  COMPLETED(5), QUIT(6), DISPUTE(7);
        private int value;

        private ProjectStatus(int value) {
            this.value = value;
        }
    }

    public UserInProject() {
    }

    public UserInProject(long contractorId, long projectId, ProjectStatus status) {
        this.contractorId = contractorId;
        this.projectId = projectId;
        this.status = status;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "contractorInProject_id", nullable = false, length = 11)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getContractorId() {
        return contractorId;
    }

    public void setContractorId(long contractorId) {
        this.contractorId = contractorId;
    }

    public long getProjectId() {
        return projectId;
    }

    public void setProjectId(long projectId) {
        this.projectId = projectId;
    }

    @Enumerated(EnumType.ORDINAL)
    public ProjectStatus getStatus() {
        return status;
    }

    public void setStatus(ProjectStatus status) {
        this.status = status;
    }
}
